<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Statistic
 *
 * @author Admin
 */
class Adv_Model_Statistic extends Zend_Db_Table_Abstract
{
    protected $_name = 'campaigns';
    
    /**
     * Выборка всех рекламных компаний указанного рекламодателя
     * @param id $idAdvertiser - id рекламодателя
     * @return array 
     */
    public function getAllAdverCampaigns($idAdvertiser) {
        $select = $this->select()
                       ->from($this->_name)
                       ->where('id_advertiser =?', intval($idAdvertiser));
        return $this->fetchAll($select)->toArray();
    }
    
    public function getSelectAdvTransactions($idAdvertiser) {
        $this->_name = 'transactions_advertisers';
        $select = $this->select()
                       ->from(array('ta' => 'transactions_advertisers'))
                       ->join(array('sp' => 'status_payment'),
                                    'ta.id_status_payment = sp.id',
                              array('status' => 'sp.status_payment'))
                       ->join(array('tp' => 'type_payment'),
                                    'ta.id_type_payment = tp.id',
                              array('type' => 'tp.type_payment'))
                       ->where('id_advertiser =?', intval($idAdvertiser))
                       ->setIntegrityCheck(false);
        return $this->fetchAll($select)->toArray();
    }
}

?>
